﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Digitalmes.Model.ProcessManagement;
using Digitalmes.Model;



namespace Digitalmes.ViewModel.ProcessManagement.ProcessResultsVMs
{
    public partial class ProcessResultsOpDetailListVM : BasePagedListVM<ProcessResults, ProcessResultsDetailSearcher>
    {
        
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("ProcessResults", GridActionStandardTypesEnum.AddRow, "新建","", dialogWidth: 800),
                this.MakeStandardAction("ProcessResults", GridActionStandardTypesEnum.RemoveRow, "删除","", dialogWidth: 800),
            };
        }
 
        protected override IEnumerable<IGridColumn<ProcessResults>> InitGridHeader()
        {
            return new List<GridColumn<ProcessResults>>{
                
                this.MakeGridHeader(x => x.TagId).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.变量"].Value),
                this.MakeGridHeader(x => x.TagName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.变量名称"].Value),
                this.MakeGridHeader(x => x.DataName).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.数据名称"].Value),
                this.MakeGridHeader(x => x.Unit).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.单位"].Value),
                this.MakeGridHeader(x => x.UpperLimit).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.上限"].Value),
                this.MakeGridHeader(x => x.LowerLimit).SetEditType(EditTypeEnum.TextBox).SetTitle(@Localizer["Page.下限"].Value),
                this.MakeGridHeader(x => x.ActiveLimit).SetEditType(EditTypeEnum.ComboBox,Utils.GetBoolCombo(BoolComboTypes.YesNo, selectText:Wtm.Localizer?["Sys.PleaseSelect"])).SetTitle(@Localizer["Page.激活上下限"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<ProcessResults> GetSearchQuery()
        {
                
            var id = (long?)Searcher.OpId.ConvertValue(typeof(long?));
            if (id == null)
                return new List<ProcessResults>().AsQueryable().OrderBy(x => x.ID);
            var query = DC.Set<ProcessResults>()
                .Where(x => id == x.OpId)

                .OrderBy(x => x.ID);
            return query;
        }

    }

    public partial class ProcessResultsDetailSearcher : BaseSearcher
    {
        
        [Display(Name = "_Model._ProcessResults._Op")]
        public string OpId { get; set; }
    }

}

